When you pass the selection formula to Crystal Reports, you use the RecordSelectionFormula property of the Report object.
Note: Formulas must conform to Crystal Reports' formula syntax.(i.e. strings embedded in single quotes while numbers not, etc.). For Crystal Reports to parse a formula it receives from the application (Visual Basic in this case), the formula must be identical to a formula that you would enter directly into the report designer. You can use the MsgBox function in Visual Basic to verify that the formula string being sent from VB is in a format that can be used by Crystal Reports.
Two ways you can use the RecordSelectionFormula property of the Report object are:
CRXReport.RecordSelectionFormula = "{Customer.Region} = 'CA'"
Note: Any dates passed to Crystal Reports must be in Crystal Reports Date format, Date(yyyy,mm,dd).
When passing a value to Crystal Reports, you use the.Text property of the FormulaFieldDefinition object.
First, you create your formula using the Crystal Reports formula language.
Place the new formula on your report where you would like to display the passed value.
If you will be sending a numeric value or date, again place an appropriate value in the formula in order to establish the data type of the formula.
The following code shows how you can send a title to your report from your VB application. As instructed above, a formula is inserted at the top of the report, and is named Title. It presently contains a space inside quotes, as in " ".
Sub Command1_Click () 'if we hard-c ode the title CRXReport.FormulaFields.Item(1).text = "'Report Title'" 'If we use the value of the Textbox Text1.Text = "This is a Title" CRXReport.FormulaFields.Item(1).text = chr(34) & Text1.text & chr(34) End Sub
The following code changes the value of a numeric formula at runtime.
Sub Command1_Click () 'if we hard-c ode the numeric value CRXReport.FormulaFields.Item(1).text = "9" 'If we use the value of a variable x = 65 CRXReport.FormulaFields.Item(1).text = x End Sub
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |